<?php


$cachers = array( //this array should be accessed only from getCacher*()
	1=>array("zbycz", "aa76b8d6-d8cc-4a24-af8f-3dd0cf2c69b0"),
	2=>array("Lemonexe", "75b99cb5-1e85-4c92-a365-ecc7bc42b25e"),
	3=>array("Machor", "5ec8548e-eb2a-4060-b3c9-099cedbb0c98"),
	4=>array("Feek92", "c89d93b1-e03f-4721-ab4d-ab8b0dcec766"),
	5=>array("barrek", "6fc2ec7d-9fd4-4211-85b1-cb75fd75e8ef"),
	6=>array("adeodatos", "2f870bd5-8f24-4066-851a-1ea30ef49e18"),
	7=>array("Whitek", "24eab242-bfa4-48df-af1b-ad0f72fd59ac"),
	8=>array("jlkcz", "b07b5d9c-6ece-41c2-ba6b-f347e9c906ca"),
	9=>array("xpolp", "38684c50-2014-4172-8b2b-cd2a5159e56e"),
	10=>array("Meda Bobo", "0c9e5dc8-5735-4416-8994-14d7584f7f14"),
	11=>array("shaked41", "504782f2-2f4e-4ac7-ad27-254cd4aff2b1"),
	12=>array("tapirx", ""),
);

function getCachers(){
	$arr = array();
	foreach ($GLOBALS["cachers"] as $k=>$v) $arr[$k] = $v[0];
	return $arr;
}
function getCacher($idx){return $GLOBALS["cachers"][$idx][0];}
function getCacherGuid($idx){return $GLOBALS["cachers"][$idx][1];}


require "dibi.min.php";
$sqllogin=array(
    'driver'   => 'mysql',
    'host'     => 'localhost',
    'username' => 'root',
    'password' => '',
    'database' => 'geo',
    'charset'  => 'utf8'
);
if(strpos($_SERVER['HTTP_HOST'], "geo.zby.cz") !== false) $sqllogin=array(
    'driver'   => 'mysql',
    'host'     => 'localhost',
    'username' => 'zby-3',
    'password' => 'geoteam7',
    'database' => 'zby-3',
    'charset'  => 'utf8'
);

dibi::connect($sqllogin, 1);

if (!dibi::isConnected()){
	header("HTTP/1.1 503 Service Unavailable");
	echo "error_db_unavailable.tpl";
	exit;
}
dibi::query("SET NAMES 'utf8'");
/*knihovna dibi - compact od dgx [www.dgx.cz]*/






function curl_getpage($url, $post=false){
	$ch = curl_init($url);

	if($post){
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, build_http_query($post));
	}
	//POST požadavek
	//curl_setopt($ch, CURLOPT_COOKIE, "ASP.NET_SessionId=415t5u45cl22ix55q31t5s55; userid=6031afb2-0faf-4add-9dc5-9728f84238dd");

	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible, MSIE 6.0, Windows NT 5.0)");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$page = curl_exec($ch);
	echo curl_error($ch);
	curl_close($ch);
	return $page;
}
function frurl($nadpis){
	$url = $nadpis;
	$url = preg_replace('~[^\\pL0-9_]+~u', '-', $url);
	$url = trim($url, "-");
	$url = iconv("utf-8", "us-ascii//TRANSLIT", $url);
	$url = strtolower($url);
	$url = preg_replace('~[^-a-z0-9_]+~', '', $url);
	return $url;
}
function build_http_query($array){
	foreach($array as $key=>$val)
		$str .= ($str?'&':'') . rawurlencode($key) . "=" . rawurlencode($val);
	return $str;
}
	
	

function page_header($title=false){
	
	if(function_exists("get_header")){
   add_filter('wp_title', create_function('$a', 'return "'.$title.' ~";'));
	 get_header();
	 echo '<div id="obsah">';
	 return;
  }

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title><?php echo $title; ?></title>
<style type="text/css">
body{
padding:0;
margin:0.5em;
font-family:Verdana,Geneva,Arial,Helvetica,sans-serif;line-height:1.4;font-size:80%;}
label{padding-right:1em;}

.loghead {
	border-top:1px gray solid;
	background: #eee;
	padding: 0.1em 0.5em;
	
}

.sudy, .lichy {
	padding: 0 1em;
	margin: 0 -0.5em;
	border-left: 0.5em #cf6 solid;
	border-right: 0.5em #cf6 solid;

	margin-bottom: 1em; 
}

.lichy {border-color:  #c9f;}


/*
.sudy .loghead {
	background: #FCCC72;
	border-color: #F5AB21;
	
	url: http://colorschemedesigner.com/#2x32BrGuJlXJD; 
}
.sudy .logtext {background: #FCE2B1;}
*/


.lichy .loghead, #zelena { 
	background: #B5F66F;
	border-color: #5FA80F;
}
.lichy .logtext {background: #D7F7B4;}



.loghead span.left {
	display: block;
	float:left;
	width: 20em;
}
.logtext {
	padding: 0.5em 0.3em 1em 0.3em;
}

img { vertical-align: text-bottom; }

td {text-align: center;}

</style>
</head>
<body>
<?php
	if($title) echo "<h1>$title</h1>\n\n"; 
}

function page_footer(){
	
	echo '<p style="text-align:right;font-size:80%;margin-top:4em;"><a href="http://code.google.com/p/geoteam-stats">Geoteam stats</a> 1.42 | (c) <a href="http://www.zby.cz/" style="color:#000;text-decoration:none"><b>zby.cz</b></a> <span title="24.06.2010">&#39;10</span></p>';

	if(function_exists("get_footer")){
	 echo '</div>';
   get_sidebar();	 
   get_footer();
	 return;
  }
  
	echo '</body>';
	echo '</html>';
}
